﻿@model IEnumerable<verk2013_project_group12.Models.GameInstance>


@{
    ViewBag.Title = "Game Lobby";
}

@section JavaScript
{
     <script src="@Url.Content("~/Scripts/GameLobby.js")" type="text/javascript"></script>
}
<h2>Game Lobby</h2>

<section id="Images">
   @Html.Action("_GameFilter", "Games")
</section>

<div id="newGameLobby">
<a href="@Url.Action("StartNewGame", "Games")" target="_blank" class="buttonLink">Start a new game</a>
</div>


<div id="gaming">
<table id="gameLobbyTable" class="sortable"> 
 <thead>   
    <tr>
        <th>ID</th>
        <th>Game</th>
        <th>Players</th>
        <th>Status</th>
        <th>Join</th>
        <th>Invite</th>
    </tr>
</thead>
<tbody>
@foreach (var instance in Model)
{
    
   <tr>
       <td>@instance.ID</td>
       @if (instance.GameID == 1)
       {
           <td>Tic-Tac-Toe</td>
       }
       @if (instance.GameID == 2)
       {
           <td>Yahtzee</td>
       }
       <td>@instance.CurrentPlayers / @instance.PlayerCap</td>
       @if (instance.Running)
       {
           <td>Running</td>
       }
       else
       {
           <td>Waiting</td> 
       }
       @if (instance.GameID == 1)
       {
           <td>@Html.ActionLink("Join game", "TicTacToe", new { id = instance.ID }, new { target = "_blank" })</td>
       }
       else if (instance.GameID == 2)
       {
           <td>@Html.ActionLink("Join game", "Yahtzee", new {id = instance.ID}, new { target = "_blank" })</td>
       }
           <td>@Html.ActionLink("Invite", "Invite", new {id = instance.ID})</td>
   </tr>
}
</tbody>
</table>
</div>